//导入重置样式
require("../../assets/css/reset.css");
//导入公共样式
require("../../assets/css/basic.css");
//导入标准样式
require("../../assets/css/normalize.css");
//导入iconfont.css
require("../../assets/fonts/iconfont.css");
//导入tabbar公共底部导航
require("../../assets/css/tabbar.less");
//导入navbar运动页面顶部导航
require("../../assets/css/navbar.less");
//导入样式
require("./sports_run.less");
//引入js模块
const dom = require("../../utils/dom.js");
//引入axios公共工具
const axios = require("../../utils/axios.js");

document.addEventListener("DOMContentLoaded", function () {
	//渲染tabbar
	dom.tabbar("sports");
	//渲染navbar
	dom.navbar("run");
	//渲染总里程数
	axios.get("/api/exercise").then((res) => {
		dom.get("#total").textContent = res.data.data.sum7Meter / 1000;
	});
	//点击go显示倒计时
	dom.get("#go").addEventListener("click", function () {
		dom.get("#mask").style.display = "block";
		dom.get("#box").style.display = "block";
		//开始倒计时
		let n = 3;
		setInterval(function () {
			n--;
			dom.get("#box").textContent = n;
			if (n === 0) {
				location.href = "sports_running.html";
			}
		}, 1000);
	});
});
